package com.lzh.maker.generator.file;

import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;

/**
 * 动静结合生成
 *
 * @author lzh
 * @version 1.0
 * @date 2025/3/29
 */
public class FileGenerator {
    public static void doGenerate(Object dateModel) throws IOException, TemplateException {
        // 1. 静态文件生成
        String projectPath = System.getProperty("user.dir");
        String parentPath = new File(projectPath).getParent();
        String inputPath = parentPath + File.separator + "hzi-generator-demo-projects" + File.separator + "acm-template";
        String outputPath = projectPath;
        StaticFileGenerator.copyFilesByHutool(inputPath, outputPath, true);

        // 2. 动态文件生成
        String dynamicInputPath = projectPath + File.separator + "src/main/resources/templates/MainTemplate.java.ftl";
        String dynamicOutputPath = projectPath + File.separator + "acm-template/src/com/lzh/acm/MainTemplate.java";
        DynamicFileGenerator.doGenerate(dynamicInputPath, dynamicOutputPath, dateModel);
    }
}
